package com.dcy.daily.skill.rabbitMQ.springAMQP;

import com.dcy.daily.skill.rabbitMQ.springAMQP.util.AmqpUtil;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

/**
 * 临时测试用例，后续将要删除
 * @author duanchunyu
 * @version 1.0.0
 * @createTime 2021年07月22日 10:39
 */
public class UsageTem {
    public static void main(String[] args) {
        //类似于Channel分为（RabbitAdmin+RabbitTemplate）声明队列信息
        RabbitAdmin admin = AmqpUtil.getRabbitAdmin();
        admin.declareQueue(new Queue("myqueue"));
        //发送与接收消息
        RabbitTemplate template = AmqpUtil.getRabbitTemplate();
        template.setConfirmCallback((correlationData,ack,cause)->{

        });
        template.setReturnCallback((message,replyCode,replyText,exchange,routingKey)->{

        });
        template.setBeforePublishPostProcessors();
        template.convertAndSend("myqueue","foo");
        String foo = (String) template.receiveAndConvert("myqueue");
        System.out.println(foo);
    }
}
